<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>用户登录</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css">
  <script type="text/javascript">
    function checkForm() {
      //判断用户是否输入的学号和密码
      var username = document.getElementById("username").value;
      var password = document.getElementById("password").value;
      if (username == null || username === "") {
        document.getElementById("error").innerHTML = "学号不能为空";
        return false;
      }
      if (password == null || password === "") {
        document.getElementById("error").innerHTML = "密码不能为空";
        return false;
      }

      return true;
    }
  </script>
  <style>
    body {
      background: linear-gradient(to bottom right, #007BFF, #cccccc);
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
      margin: 0;
    }

    .login-container {
      background-color: rgba(255, 255, 255, 0.9);
      border-radius: 10px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      padding: 30px;
      width: 400px;
    }

    h2 {
      text-align: center;
      margin-bottom: 30px;
      color: #333;
    }

    form label {
      font-weight: bold;
      margin-bottom: 5px;
    }

    form input[type="text"],
    form input[type="password"] {
      width: 100%;
      padding: 12px;
      margin-bottom: 20px;
      border: 1px solid #ccc;
      border-radius: 5px;
    }

    form input[type="submit"] {
      width: 100%;
      padding: 12px;
      background-color: #007BFF;
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    form input[type="submit"]:hover {
      background-color: #0056b3;
    }

    .error-message {
      color: red;
      margin-top: 10px;
      text-align: center;
    }
  </style>
</head>

<body>
<div class="login-container">
  <h2>超市库存管理系统</h2>
  <form action="${pageContext.request.contextPath}/login" method="post" onsubmit="return checkForm()">
    <div class="mb-3">
      <label for="username" class="form-label">用户名</label>
      <input type="text" class="form-control" id="username" name="username" required>
    </div>
    <div class="mb-3">
      <label for="password" class="form-label">密码</label>
      <input type="password" class="form-control" id="password" name="password" required>
    </div>
    <input type="submit" class="btn btn-primary" value="登录">
    <div class="error-message">
      <%= request.getAttribute("errorMessage")!= null? request.getAttribute("errorMessage") : "" %>
    </div>
  </form>
</div>
</body>

</html>